package main

import (
	"01/retriever/mock"
	"fmt"
	"io"

	"golang.org/x/tools/0.20210908190839-cf92b39a962c/go/analysis/passes/inspect"
)

type Retriever interface {
	Get(url string) string
}

func download(r Retriever) string {
	return r.Get("www.imooc.com")
}

type Rf interface {
	Post(url string) string
	Get()
}

func main() {
	// var r Retriever
	var r Retriever
	fmt.Printf("%T, %v\n", r, r)
	r = &mock.Retriever{"this is me"}
	fmt.Printf("%T, %v\n", r, r)
	fmt.Println(download(r))

	// switch 可以获取 r的 类型
	switch v := r.(type) {
	case *mock.Retriever:
		fmt.Println(v.Contents)
	}

	// Type assertion (类型断言)
	mockRetriever, ok := r.(*mock.Retriever)  // 当为值时，就是r.(mock.Retriever)
	// ok用来判断 类型判断是否正确
	fmt.Println(ok, mockRetriever.Contents)


	q := []interface{} {1, "ahah", '1'}

	inspect(q)
	 
}
